// http://developer.mozilla.org/en/docs/Creating_a_dynamic_status_bar_extension
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
                    .getService(Components.interfaces.nsIPrefService).getBranch("extensions.perseus.");
var enabled = prefs.getBoolPref("enable");

var ConvStatusBar = {

	startup: function(){
                 this.statusImage = document.getElementById("conv-status-image");
                 var enabled = prefs.getBoolPref("enable");
              //   this.convbar = 	document.getElementById('status-bar-conv-1');
                 var obs = Components.classes["@mozilla.org/security/perseusobserver;1"]  
                     .getService(Components.interfaces.nsIPerseus);

                 if(enabled) {
                     //    this.convbar.label="On";
                     this.statusImage.src = "chrome://perseus/content/skin/icon_small.png";
                     obs.perseusOn();
                 } else {
                     ///    this.convbar.label="Off";
                     this.statusImage.src = "chrome://perseus/content/skin/icon_smallOff.png";
                     obs.perseusOff();
                 }

	},
	getStatus : function(){
		return value;
	},
	onClick: function(){
		var enabled = prefs.getBoolPref("enable");
        var obs = Components.classes["@mozilla.org/security/perseusobserver;1"]  
                .getService(Components.interfaces.nsIPerseus);

		if(enabled) {
			//this.convbar.label="Off";
            this.statusImage.src = "chrome://perseus/content/skin/icon_smallOff.png";
            obs.perseusOff();
        } else {
            //this.convbar.label="On";
            this.statusImage.src = "chrome://perseus/content/skin/icon_small.png";
            obs.perseusOn();
        }
		prefs.setBoolPref("enable", !enabled); // set a pref
  },


};


window.addEventListener("load", function(e) { ConvStatusBar.startup(); }, false);


